package myFind;

public class BSTExam {
    public static void main(String[] args) {

        int[] a = {3, 5, 6, 2, 4, 3};
        BSTClass bt = new BSTClass();
        for (int j : a) System.out.print(j + " ");
        System.out.println();
        System.out.println("创建BST");
        bt.createBST(a);
        System.out.print("BST: ");
        bt.dispBST();
        System.out.println();
        System.out.print("插入10, BST: ");
        bt.insertBST(10);
        bt.dispBST();
        System.out.println();
        System.out.print("插入10, BST: ");
        bt.insertBST(10);
        bt.dispBST();
        System.out.println();
        int k = 3;
        System.out.print("查找" + k + ",结果" + (bt.searchBST(k) == null ? 0 : 1));
        System.out.println();
        k = 4;
        System.out.print("删除" + k + ", BST: ");
        bt.deleteBST(k);
        bt.dispBST();
        System.out.println();
        k = 3;
        System.out.print("删除" + k + ", BST: ");
        bt.deleteBST(k);
        bt.dispBST();
        System.out.println();
        k = 1;
        System.out.print("删除" + k + ", BST: ");
        bt.deleteBST(k);
        bt.dispBST();
        System.out.println();

        k = 2;
        System.out.print("删除" + k + ", BST: ");
        bt.deleteBST(k);
        bt.dispBST();
        System.out.println();
        k = 5;
        System.out.print("删除" + k + ", BST: ");
        bt.deleteBST(k);
        bt.dispBST();
        System.out.println();
        k = 6;
        System.out.print("删除" + k + ", BST: ");
        bt.deleteBST(k);
        bt.dispBST();
        System.out.println();

        int[] a2 = {1, 2, 3, 4, 5};
        BSTClass bt2 = new BSTClass();
        for (int j : a2) System.out.print(j + " ");
        System.out.println();
        System.out.println("创建BST");
        bt2.createBST(a2);


    }
}

 